<%--
  Created by IntelliJ IDEA.
  User: xinlong
  Date: 2017/10/17
  Time: 0:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>后台登录</title>
    <%@include file="/resources/common/head.jsp" %>
    <style type="text/css">
        *{
            margin: 0;
            padding: 0;
            font-family: Microsoft Yahei;
        }
        body{
            background: url(/resources/images/login-background.png) no-repeat fixed center center;
        }
        a{
            text-decoration:none;
        }
        #container{
            width:100%;
            position: absolute;
        }
        #header{
            height: 30px;
            line-height: 30px;
            color: #666;
            width: 100%;
            background-color: #1E1B29;
            overflow: hidden;
        }
        .header-panel{
            max-width: 1000px;
            margin:0px auto;
        }
        .left{
            float: left;
        }
        .left a{
            padding-left: 15px;
            padding-right: 15px;
        }
        .left a:link,.left a:visited,.left a:hover,.left a:active{
            color: #33A3DC;
        }
        .right{
            float: right;
        }
        .right a{
            padding-left: 15px;
            padding-right: 15px;
        }
        .right a:link,.right a:visited,.right a:hover,.right a:active{
            color: #999;
        }
        #center{
            max-width: 1000px;
            margin:0px auto;
            padding-top: 50px;
            color: #fff;
        }
        .icon{
            max-width: 1000px;
            margin: 0px auto;
            max-height: 90px;
        }
        .icon img{
            max-height: 90px;
        }
        .login-panel{
            width: 310px;
            height: 290px;
            margin: 20px auto;
            margin-right: 90px;
            background-color: RGBA(0,0,0,0.5);
        }
        .login-panel-header{
            padding-top: 15px;
            width: 100%;
            height: 27px;
            border-bottom: 3px solid #33A3DC;
            text-align: center;
            font-size: 18px;
            margin-bottom: 20px;
        }
        .login-panel a{
            background:transparent !important;
            color: #fff !important;
        }
        .login-panel a:hover{
            color: #7bbfea !important;
            background:transparent;outline:0;text-decoration:none;
        }
        .login-panel a {transition: color 0.3s ease-in-out;}
    </style>
</head>
<body>
<div id="container">
    <div id="header">
        <div class="header-panel">
            <div class="left">
                <a href="#">wetravel</a>
            </div>
            <div class="right">
                <a href="#">首页</a>
                <a href="#">服务大厅</a>
                <a href="#">提建议</a>
            </div>
        </div>
    </div>
    <div id="center">
        <div class="icon">
            <img src="/resources/images/icon/威旅商标.png" />
        </div>
        <div class="login-panel">
            <div class="login-panel-header">账密登录</div>
            <form id="login" class="layui-form">
                <div class="layui-form-item">
                    <div class="layui-row">
                        <label class="layui-form-label layui-col-xs2">账号</label>
                        <div class="layui-input-inline layui-col-xs10">
                            <input type="text" name="username" required  lay-verify="required" placeholder="请输入账号" autocomplete="off" class="layui-input" >
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-row">
                        <label class="layui-form-label layui-col-xs2">密码</label>
                        <div class="layui-input-inline layui-col-xs10">
                            <input type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <!-- 				  <div class="layui-form-item">
                                      <label class="layui-form-label" style="width: 140px">两周内自动登录</label>
                                      <input type="checkbox" name="switch" lay-skin="switch">
                                  </div> -->
                <div class="layui-form-item">
                    <div class="layui-row">
                        <button id="commit" class="layui-btn layui-col-xs10 layui-col-xs-offset1" lay-filter="formDemo">立即提交</button>
                    </div>
                </div>
            </form>
            <div class="layui-row">
                <a class="layui-col-xs3 layui-col-xs-offset1" href="/user/register">免费注册</a>
                <a class="layui-col-xs3 layui-col-xs-offset5" href="/user/forget">忘记密码</a>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    layui.config({
        base: '/resources/res/js/modules/' //你存放新模块的目录，注意，不是layui的模块目录
    }).use('index'); //加载入口

    //绑定提交事件
    $('#commit').click( function () {
        var status = 1;
        //发送请求
        $.ajax({
            type:"post",
            url:"/user/login.do",      // 这里是提交到什么地方的url
            data:$('#login').serialize(),            // 这里把表单里面的数据放在这里传到后台
            dataType:"json",
            async: false,       //设置ajax请求为同步，防止发送请求后执行success代码异常
            success:function(res){
                if(res.status==0){
                    status = 0;
                }
            },
            error:function(res){
                if(res.status==0){
                    status = 0;
                }
            }
        });
        if(status == 0){
            setTimeout("javascript:location.href=wetravel.URL.index()", 1);
        }else {
            alert("登录失败，用户名或密码错误");
        }
    });

</script>
</body>
</html>